//
//  HomeTransferOrderTableViewCell.m
//  ZJControlsClass
//
//  Created by mac on 2024/12/3.
//

#import "HomeTransferOrderTableViewCell.h"
#import "HomeTransferOrderInfoViewController.h"


@interface HomeTransferOrderTableViewCell ()

@property (nonatomic,strong) UIView * follewView;
@property (nonatomic,strong) UILabel * codeLabel;
@property (nonatomic,strong) UILabel * goodsLabel;
@property (nonatomic,strong) UILabel * timeLabel;
@property (nonatomic,strong) UIView * v;

@property (nonatomic,strong) UIButton * transforBtn;


@end



@implementation HomeTransferOrderTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self){
        self.contentView.backgroundColor = COLOR_RGB(241, 241, 241);
        [self configUI];
    }
    
    return self;
}


-(void)setModel:(HomeTransforOrderModel *)model{
    _model = model;
    
    self.codeLabel.text = [NSString stringWithFormat:@"业务编号：%@",model.sourceId];
    self.goodsLabel.text = [NSString stringWithFormat:@"携带货品：%@",model.type];
    self.timeLabel.text = [NSString stringWithFormat:@"通行有效期：%@",model.createTime];
    
    
}




-(void)configUI{
    
    [self.contentView addSubview:self.follewView];
    [self.follewView addSubview:self.codeLabel];
    [self.follewView addSubview:self.goodsLabel];
    [self.follewView addSubview:self.timeLabel];
    [self.follewView addSubview:self.v];
    [self.follewView addSubview:self.transforBtn];
    
    [self.follewView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(ALIGN_WIDTH_PT(12));
        make.top.equalTo(self.contentView).with.offset(ALIGN_WIDTH_PT(10));
        make.bottom.equalTo(self.contentView);
        make.right.equalTo(self.contentView).with.offset(-ALIGN_WIDTH_PT(12));
    }];
    
    [self.codeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.follewView).with.offset(ALIGN_WIDTH_PT(10));
        make.top.equalTo(self.follewView).with.offset(ALIGN_WIDTH_PT(16.5));
        make.right.equalTo(self.follewView).with.offset(-ALIGN_WIDTH_PT(10));

    }];
    
    [self.goodsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.codeLabel.mas_left);
        make.top.equalTo(self.codeLabel.mas_bottom).with.offset(ALIGN_WIDTH_PT(14));
        make.right.equalTo(self.codeLabel.mas_right);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.codeLabel.mas_left);
        make.top.equalTo(self.goodsLabel.mas_bottom).with.offset(ALIGN_WIDTH_PT(5));
        make.right.equalTo(self.codeLabel.mas_right);
    }];
    
    [self.v mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.codeLabel.mas_left);
        make.top.equalTo(self.timeLabel.mas_bottom).with.offset(ALIGN_WIDTH_PT(15));
        make.right.equalTo(self.codeLabel.mas_right);
        make.height.equalTo(@(1));
    }];
    
    [self.transforBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.codeLabel.mas_right);
        make.top.equalTo(self.v.mas_bottom).with.offset(ALIGN_HEIGHT_PT(12));
        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(80), ALIGN_HEIGHT_PT(28))));
    }];
    
    
    
    
    
}





#pragma mark -- 点击事件
-(void)respondsTo_transforBtn{
    HomeTransferOrderInfoViewController * vc = [HomeTransferOrderInfoViewController new];
    vc.ID = self.model.sourceId;
    [[SaViewControllerUtils currentViewController].navigationController pushViewController:vc animated:YES];
}



#pragma mark -- 懒加载
-(UIView *)follewView{
    if (!_follewView){
        _follewView = [UIView new];
        _follewView.backgroundColor = [UIColor whiteColor];
        _follewView.layer.cornerRadius = 8;
        _follewView.layer.masksToBounds = YES;
    }
    return _follewView;
}

-(UILabel *)codeLabel{
    if (!_codeLabel){
        _codeLabel = [UILabel new];
        _codeLabel.textColor = [UIColor blackColor];
        _codeLabel.font = FONT14;
        _codeLabel.textAlignment = NSTextAlignmentLeft;
        _codeLabel.text = @"业务编号：5327532095832095823058";
    }
    return _codeLabel;
}


-(UILabel *)goodsLabel{
    if (!_goodsLabel){
        _goodsLabel = [UILabel new];
        _goodsLabel.textColor = COLOR_RGB(102, 102, 102);
        _goodsLabel.font = FONT14;
        _goodsLabel.textAlignment = NSTextAlignmentLeft;
        _goodsLabel.text = @"携带货品：货物";
    }
    return _goodsLabel;
}

-(UILabel *)timeLabel{
    if (!_timeLabel){
        _timeLabel = [UILabel new];
        _timeLabel.textColor = COLOR_RGB(102, 102, 102);
        _timeLabel.font = FONT14;
        _timeLabel.textAlignment = NSTextAlignmentLeft;
        _timeLabel.text = @"通行有效期：2024.12.3 09:08-202";
    }
    return _timeLabel;
}

-(UIView *)v{
    if (!_v){
        _v = [UIView new];
        _v.backgroundColor = COLOR_RGB(228, 228, 228);
    }
    return _v;
}

-(UIButton *)transforBtn{
    if (!_transforBtn){
        _transforBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_transforBtn setTitle:@"转单" forState:(UIControlStateNormal)];
        _transforBtn.titleLabel.font = FONT14;
        [_transforBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        _transforBtn.backgroundColor = COLOR_RGB(50, 113, 237);
        _transforBtn.layer.cornerRadius = 5;
        _transforBtn.layer.masksToBounds = YES;
        [_transforBtn addTarget:self action:@selector(respondsTo_transforBtn) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _transforBtn;
}



@end
